/*
 * \class getVacinityEvents
 * \brief This class handles the actual business user side content
 * \author Sicelo Cel
 * \author Salman Noor
 * \author Mahlatse Maraba
 */

$(function(){
    getVacinityEvents(-26,28);

    $( "#eventTabs" ).tabs();

    jQuery("#eventTabs").tabs('select', 0);
    jQuery("#eventTabs").bind('tabsselect', function(event, ui) {
        selectedTab = ui.index;
        if (selectedTab == 2)
        {
            $("#directionsToEventContainer").show('slow');
        }
        else
        {
            $("#directionsToEventContainer").hide('slow');
        }
    });
    $( "#selectables" ).selectable();

    //$( "#accordion" ).accordion();

    $( "#rightNavMainLinksHolder button:first" ).button({
        icons: {
            primary: "ui-icon-home",
            secondary: "ui-icon-home"
        },
        text: true
    }).next().button({
        icons: {
            primary: "ui-icon-person",
            secondary: "ui-icon-note"
        },
        text: true
    }).next().button({

        icons: {
            primary: "ui-icon-person",
            secondary: "ui-icon-note"
        },
        text: true
    });
        
    $("#goBackToHome").click(function(){

        window.location.href="http://localhost/stellogoogle/eventsmanager/";
        jQuery("#customerDiv").slideUp('slow');
        jQuery("#homeDiv").show('slow');
        jQuery("#customerDiv").empty();
    });

    $('.sideMainNavLinks .ui-button-text').css('width','300px');


    //
    $("#JoinEvent").button({

        icons: {
            primary: 'ui-icon-circle-arrow-n',
            secondary: 'ui-icon-circle-arrow-n'
        },
        text: true
    });



    $( "#JoinEvent" ).button( "option", "disabled", true );


    var JoiningEvent = $("#Join Event");
    var Event = $("#SigtnInForEvent");
    var Weather = $('#getWeather').button();
    var getDirection = $('#GetDrivingDirections').button();
    var EventMap = $('#getDirectionMap').button();
    var SiteEvent = $('#Site').button();

    $( "#selectables" ).selectable({
        stop: function() {
            var result = $( "#select-result" ).empty();
            $( ".ui-selected", this ).each(function() {
                var index = $( "#selectables li" ).index( this );
                var relIndex = index + 1;
                if (relIndex <= 0 || relIndex ==  null ) {
                    $( "#JoinEvent" ).button( "option", "disabled", true );
                }
                else
                {
                    $( "#JoinEvent" ).button( "option", "disabled", false );
                }
            });
        }
    });

    $("#dialog-activity-lister").dialog({
        resizable: true,
        width: 740,
        modal: true,
        show: 'clip',
        hide: 'clip',
        autoOpen: true,
        closeOnEscape: true,
        buttons: {
            'Ok': function() {

            },
            "Cancel": function() {
                jQuery(this).dialog("close");
            }
        }

    })
    $("#dialog-activity-lister").dialog('close');


})















